<?php

use yii\db\Migration;

/**
 * Class m191009_075618_new_project
 */
class m191009_075618_new_project extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="项目表"';
        $this->createTable('{{%new_project}}', [
            'id' => $this->primaryKey(),
            'title'=>$this->string()->unique()->notNull()->comment('名称'),
            'class_id'=>$this->string()->notNull()->comment('项目分类'),
            'tags'=>$this->text()->notNull()->comment('类型标签'),
            'area'=>$this->string()->notNull()->comment('地区'),
            'movie_time'=>$this->string()->comment('片长'),
            'release_time'=>$this->integer(10)->comment('上映时间'),
            'pic'=>$this->string()->notNull()->comment('封面图'),
            'background_img'=>$this->string()->notNull()->comment('背景图'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('1:启用 2:停用 3:删除'),
            'is_recommend'=> $this->smallInteger()->notNull()->defaultValue(1)->comment('1:是 2:否'),
            'uid'=> $this->Integer()->notNull()->comment('发布人id'),
            'introduction'=>$this->text()->notNull()->comment('项目简介'),
            'advertisement'=>$this->text()->notNull()->comment('宣发计划'),
            'policy'=>$this->text()->comment('政策优势'),
            'theme'=>$this->text()->comment('题材优势'),
            'market'=>$this->text()->comment('市场优势'),
            'case'=>$this->text()->comment('相关案例'),
            'click_num'=>$this->bigInteger()->defaultValue(0)->comment('浏览人数'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);

    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%new_project}}');
        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m191009_075618_new_project cannot be reverted.\n";

        return false;
    }
    */
}
